package day07.demo;

import java.util.Random;
import java.util.Scanner;

/**
 * 1.需求:猜数字小游戏
 *   训练目标: while(true)自造死循环+break
 */
public class Guressing02 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        Random rd=new Random();

        int num= rd.nextInt(100+1);
        System.out.println("num="+num);//0-100的随机数
        while (true){
            System.out.println("猜吧");
            int scnum= sc.nextInt();
            if (scnum>num){
                System.out.println("大了");
            }else if(scnum<num){
                System.out.println("小了");
            }else {
                System.out.println("恭喜你");
                break;

            }
        }
    }
}
